package com.allianz.webapps.controllers;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.allianz.webapps.https.interfaces.appSaveRisaAccessment.AppSaveRisaAccessment;
import com.allianz.webapps.https.interfaces.util.HttpsUtil;
import com.allianz.webapps.orderspojo.App;
import com.fasterxml.jackson.databind.ObjectMapper;

@Controller
@RequestMapping(value = "main")
public class AppSaveRisaAccessmentController {
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private AppSaveRisaAccessment appSaveRisaAccessment;
	@RequestMapping("appsaverisaaccessment")
	@ResponseBody
	public void appsaverisaaccessment(
			@RequestParam(value = "jsonParam") String jsonParam,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		App apprq=objectMapper.readValue(jsonParam, App.class);
		String body1 = HttpsUtil.httpsPost(appSaveRisaAccessment.requestAppSaveRisaAccessmentParam(apprq));
		JSONObject json = new JSONObject(body1);
		if(!"S".equals(json.getString("Status")))
			throw new Exception(json.getString("ErrMsg"));
	}
}
